package web.java.d_test;

import static org.junit.Assert.*;

import java.util.List;

import org.apache.commons.beanutils.BeanUtils;
import org.junit.Test;

import web.java.c_Dao.EmpDao;

public class Demo02_testEmpDao {
	/**
	 * 添加
	 * */
	@Test
	public void testAdd() throws Exception {
		EmpDao empdao=new EmpDao();
		Emp emp=new Emp();
		BeanUtils.copyProperty(emp,"emp_name","测试数据三");
		BeanUtils.copyProperty(emp,"emp_age","22");
		BeanUtils.copyProperty(emp,"emp_salary","2222");
		BeanUtils.copyProperty(emp,"emp_consume","22222");
		BeanUtils.copyProperty(emp,"emp_gender","男");
		System.out.println(emp);
		int result=empdao.add(emp);
		System.out.println(result);
	}
	/**
	 * 修改
	 * */
	@Test
	public void testModify() throws Exception {
		EmpDao ed=new EmpDao();
		Emp emp=new Emp();
		BeanUtils.copyProperty(emp,"emp_id","26");
		BeanUtils.copyProperty(emp,"emp_name","测试数据三");
		BeanUtils.copyProperty(emp,"emp_age","23");
		BeanUtils.copyProperty(emp,"emp_salary","23333");
		BeanUtils.copyProperty(emp,"emp_consume","2333");
		BeanUtils.copyProperty(emp,"emp_gender","女");
		int result=ed.modify(emp);
		System.out.println(result);
	}
	/**
	 * 删除
	 * */
	@Test
	public void testDel() throws Exception {
		EmpDao ed=new EmpDao();
		int result=ed.delete(24);
		System.out.println(result);
	}
	/**
	 * 查询全部
	 * */
	@Test
	public void testShow() throws Exception {
		EmpDao ed=new EmpDao();
		List<Emp> list=ed.getAll();
		for(Emp emp:list){
			System.out.println(emp);
		}
	}
	/**
	 * 单个查询
	 * */
	@Test
	public void testSingle() throws Exception {
		EmpDao ed=new EmpDao();
		Emp emp=ed.get(25);
		System.out.println(emp);
	}
}
